Skip to content

Add the polars export format - #1727

Merged
jschoedl merged 6 commits into
datacontract:mainfrom
DariusHQ:polars-exporter
Oct 30, 2026
Merged

jschoedl merged 6 commits into
datacontract:mainfrom
DariusHQ:polars-exporter

Conversation

@DariusHQ

Copy link
Copy Markdown
Contributor

Closes #1552.

datacontract export polars writes a Python module with one pl.Schema per schema, and polars does not need to be installed to run it. Widths and precisions come from the physical type (int32, float32, decimal(10,2), timestamp(9)), then from the ODCS format of an integer or number (i16, u32, f32), then from the logical type. Maps become lists of key-value structs, as Polars reads Arrow maps, and vectors fixed-size arrays.

  • Tests pass (uv run pytest)
  • Code formatted (uv run ruff check --fix && uv run ruff format)
  • Docs updated (if relevant)
  • CHANGELOG.md entry added

DariusHQ and others added 4 commits October 10, 2026 17:15
A decimal wider than 38 digits now fails with "Schema 'orders': Polars decimals hold at most 38 digits, but 'amount' has a precision of 40.", so the field can be found when several schemas share a field name.

@jschoedl jschoedl left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much! One small note, and I took the liberty to shorten a few docstrings, as they accumulate (and outdate) quite quickly these days :)

Comment thread datacontract/export/polars_exporter.py Resolved
tinyint, smallint, int, integer, float, float4 and real no longer map to a fixed
width, since BigQuery and Snowflake read them differently: they now export as
Int64 or Float64 from the logical type, as int8 already did.
@jschoedl
jschoedl merged commit c7e98f7 into datacontract:main Oct 30, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Native Polars exporter for Data Contract CLI

3 participants